package com.itheima.chapter08.stream;

import java.lang.reflect.Array;
import java.util.ArrayList;

//体验stream
public class demo1 {
    public static void main(String[] args) {
        ArrayList<String> list =new ArrayList<>();
        list.add("张茅于");
        list.add("张一一");
        list.add("林宏杰");
        list.add("李湘");
        list.add("张开始");
        list.add("张开");
        ArrayList<String> list1 =new ArrayList<>();
        for (String s : list) {
            if (s.startsWith("张")){
                list1.add(s);
            }
        }
        System.out.println(list1);
        ArrayList<String> list2 =new ArrayList<>();
        for (String s1 : list1) {
            if (s1.length()==3){
                list2.add(s1);
            }
        }
        System.out.println(list2);
        System.out.println("---------------------------");
        list.stream().filter(s->s.startsWith("张")).filter(s->s.length()==3).forEach(s-> System.out.println(s));


    }
}
